﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Simple.Repository.Migrations
{
    public partial class _14 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Slideshow",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    Title = table.Column<string>(type: "longtext", nullable: true, comment: "标题")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Source = table.Column<int>(type: "int", nullable: false, comment: "来源 1-内部，2-外部"),
                    SourceType = table.Column<int>(type: "int", nullable: true, comment: "来源1-内部(文章-1或课程-2类别)"),
                    HttpURL = table.Column<string>(type: "longtext", nullable: true, comment: "2-外部(http地址)")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ObjectId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "1-内部（文章Id或课程Id）", collation: "ascii_general_ci"),
                    SortValue = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    IsShow = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否可见"),
                    ShowRange = table.Column<int>(type: "int", nullable: false, comment: "显示区域1-家长，2-园务"),
                    ContentTitle = table.Column<string>(type: "longtext", nullable: true, comment: "链接内容")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Slideshow", x => x.Id);
                },
                comment: "轮播图管理")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Slideshow_Image",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    FiledId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "文件Id", collation: "ascii_general_ci"),
                    FileName = table.Column<string>(type: "longtext", nullable: false, comment: "文件名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FileSize = table.Column<string>(type: "longtext", nullable: false, comment: "文件大小")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SlideshowId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "文章Id", collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Slideshow_Image", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Slideshow_Image_Slideshow_SlideshowId",
                        column: x => x.SlideshowId,
                        principalTable: "Slideshow",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "轮播图管理")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_Slideshow_Image_SlideshowId",
                table: "Slideshow_Image",
                column: "SlideshowId",
                unique: true);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Slideshow_Image");

            migrationBuilder.DropTable(
                name: "Slideshow");
        }
    }
}
